from tkinter import *
from tkinter.messagebox import *

tk = Tk()
tk.protocol('WM_DELETE_WINDOW', lambda: askyesno('', '关闭') and tk.destroy())
tk.mainloop()
